#ifndef SPEEDREADER_H
#define SPEEDREADER_H

#include <QObject>
#include <QTimer>
#include <QStringList>
#include "textformatreader.h"
#include "math.h"

class SpeedReader : public QObject
{
        Q_OBJECT
    public:
        explicit SpeedReader();

        QStringList getWordsToRead() const;
        int getCurrentPosition() const;
        int getCommaPauseTime() const;
        int getDotPauseTime() const;
        int getReadingSpeed() const;
        int getWordsCount() const;
        bool isShiftingEnabled() const;

    private:
        QStringList words;
        int currentPosition, commaPauseTime, dotPauseTime, wordPerMinute, wordsCount, maxWordLength;
        double readPositionPercent;
        bool shiftingEnabled;
        QTimer readingTimer, pauseTimer;
        TextFormatReader *pTextFormatReader;

        void reset();

    signals:
        void nextWordAvailable(QString, int);
        void readingProgress(double);
        void wordOffset(int);
        void error(SpeedReaderError);
        void endOfBook();

    public slots:
        void setCurrentPosition(const int &currentPosition);
        void setCommaPauseTime(const int &commaPauseTime);
        void setDotPauseTime(const int &dotPauseTime);
        void setReadingSpeed(int wordPerMinute);
        void setShiftingEnabled(const bool &shiftingEnabled);
        void setTextFormatReader(TextFormatReader *pTextFormatReader);

        void previousWord();
        void nextWord();

        void startReading();
        void stopReading();

    private slots:
        void setWordsToRead(const QStringList &words);
        void setMaxWordLength(const int &maxWordLength);
        void readWord();
};

#endif // SPEEDREADER_H
